import java.util.Stack;

public class MyQueue {

    private Stack<Integer> s1;
    private Stack<Integer> s2;

    public MyQueue() {
        s1 = new Stack<>();
        s2 = new Stack<>();
    }

    //模拟入队列
    public void push(int x) {
        s1.push(x);
    }

    //出队列
    public int pop() {
        if(empty()){
            return -1;
        }
        if(s2.isEmpty()){
            //把s1中的数据全部倒出
            while(! s1.isEmpty()){
                s2.push(s1.pop());
            }
        }
        return s2.peek();
    }

    //获取队头元素
    public int peek() {
        if(empty()){
            return -1;
        }
        if(s2.isEmpty()){
            //把s1中的数据全部倒出
            while(! s1.isEmpty()){
                s2.push(s1.pop());
            }
        }
        return s2.peek();
    }

    //两个栈都为空，则队列为空
    public boolean empty() {
        return s1.isEmpty() && s2.isEmpty();
    }
}